/**
 * Created by IntelliJ IDEA.
 * User: ibm t42
 * Date: 2012-1-15
 * Time: 22:00:21
 * To change this template use File | Settings | File Templates.
 */

var ticket =function(props){
    this.basePath =""||props.basePath;
    this.airLineCompBoxHome = "airlinecomp"||props.airLineCompBoxHome;
    this.airLineCompBoxEdit = "airlinecompedit"||props.airLineCompBoxEdit;
    this.airPortBox = "airport"||props.airPortBox;
    this.modelAirLineComp = ""||props.modelAirLineComp;
    this.modelAirPort = ""||props.modelAirPort;
}

ticket.prototype.rendAirLineCompHome=function(){
    var url =this.basePath +"/admin/airLineComp.json";
    var p = this;
    $.get(
        url,
        function(json){
            var list = json.result;
            for(var i=0;i<list.length;i++){
                var obj = list[i];
                var objHtml = "";
                if(p.modelAirLineComp && p.modelAirLineComp !="" && p.modelAirLineComp==obj.id){
                  objHtml = "<option value='"+obj.id+"' selected>"+obj.name+"</option>";
                }else{
                  objHtml = "<option value='"+obj.id+"'>"+obj.name+"</option>";
                }
                $("#"+p.airLineCompBoxHome).append(objHtml);
            }
        },
        'json'
    );
};
ticket.prototype.rendAirLineCompEdit=function(){
    var url =this.basePath +"/admin/airLineComp.json";
    var p = this;
    $.get(
        url,
        function(json){
            var list = json.result;
            for(var i=0;i<list.length;i++){
                var obj = list[i];
                var objHtml = "";
                if(p.modelAirLineComp && p.modelAirLineComp !="" && p.modelAirLineComp==obj.id){
                  objHtml = "<option value='"+obj.id+"' selected>"+obj.name+"</option>";
                }else{
                  objHtml = "<option value='"+obj.id+"'>"+obj.name+"</option>";
                }
                $("#"+p.airLineCompBoxEdit).append(objHtml);
            }
        },
        'json'
    );
};

ticket.prototype.rendAirPort=function(){
    var url = this.basePath +"/admin/airPort.json";
    var p = this;
    $.get(
        url,
        function(json){
            var list = json.result;
            for(var i=0;i<list.length;i++){
                var obj = list[i];
                var objHtml = "";
                if(p.modelAirPort && p.modelAirPort !="" && p.modelAirPort == obj.id){
                    objHtml = "<option value='"+obj.id+"' selected>"+obj.name+"</option>";
                }else{
                    objHtml = "<option value='"+obj.id+"'>"+obj.name+"</option>";
                }
                $("#"+p.airPortBox).append(objHtml);
            }

        },
        'json'
    );
}
